﻿using System;
using System.Data;
using UniversityStudentManagemnetSystem.DAO.DAL;
using UniversityStudentManagemnetSystem.DAO.Gateway;

namespace UniversityStudentManagemnetSystem.BLL
{
    public class OfficerManager
    {
        OfficerGateway officerGateway = new OfficerGateway();
        public bool SaveOfficer(Officer aOfficer)
        {
            if (officerGateway.HasThisNationalId(aOfficer.NationalIdNumber))
            {
                throw new Exception("This National Id already exist! Please try again.");
            }
            else if (officerGateway.HasThisEmail(aOfficer.Email))
            {
                throw new Exception("This email already exist! Please try again.");
            }
            else
            {
                return officerGateway.SaveOfficer(aOfficer);
            }
        }
        public int GetPreviousOfficerId()
        {
            return officerGateway.GetPreviousOfficerId();
        }
        public DataTable GetAllEmployee()
        {
            return officerGateway.GetAllOfficer();
        }

        public DataTable GetAllOfficerDesignation(int selectedDesignation)
        {
            return officerGateway.GetAllOfficerFor(selectedDesignation);
        }

        public Officer GetOficerFor(string searchText)
        {
            if (searchText != "")
            {
                return officerGateway.GetOfficerFor(searchText);
            }
            else
            {
                throw new Exception("Please fill The Search Field Properly");
            }
        }
    }
}